namespace Registro.Compras.Data.RegistroComprasDataContextMigrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Initial : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Base1s",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        FechaEmision = c.DateTime(nullable: false),
                        FechaVencimiento = c.DateTime(),
                        Tabla10Id = c.Int(nullable: false),
                        Serie = c.String(nullable: false),
                        AñoEmisionDua = c.Long(),
                        N_Comprobante = c.Long(nullable: false),
                        ProveedorId = c.Int(nullable: false),
                        BaseImponibleId = c.Int(nullable: false),
                        DescripcionM = c.String(),
                        Operacion1 = c.String(),
                        Codigo1 = c.Int(),
                        Debe1 = c.Single(),
                        Haber1 = c.Single(),
                        Codigo2 = c.Int(),
                        Debe2 = c.Single(),
                        Haber2 = c.Single(),
                        Codigo3 = c.Int(),
                        Debe3 = c.Single(),
                        Haber3 = c.Single(),
                        Operacion2 = c.String(nullable: false),
                        Codigo4 = c.Int(),
                        Debe4 = c.Single(),
                        Haber4 = c.Single(),
                        Codigo5 = c.Int(),
                        Debe5 = c.Single(),
                        Haber5 = c.Single(),
                        Operacion3 = c.String(nullable: false),
                        Codigo6 = c.Int(),
                        Debe6 = c.Single(),
                        Haber6 = c.Single(),
                        Codigo7 = c.Int(),
                        Debe7 = c.Single(),
                        Haber7 = c.Single(),
                        AdquisicionesNoGravadas = c.Single(),
                        ISC = c.Single(),
                        OtrosTributos = c.Single(),
                        ImporteTotal = c.Single(nullable: false),
                        PagoNoDomiciliado = c.Single(),
                        CDD_Numero = c.Long(),
                        CDD_FechaEmision = c.DateTime(),
                        TipodeCambio = c.Single(),
                        EncabezadoId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.BaseImponibles", t => t.BaseImponibleId)
                .ForeignKey("dbo.Encabezados", t => t.EncabezadoId)
                .ForeignKey("dbo.Proveedores", t => t.ProveedorId)
                .ForeignKey("dbo.Tabla10s", t => t.Tabla10Id)
                .Index(t => t.Tabla10Id)
                .Index(t => t.ProveedorId)
                .Index(t => t.BaseImponibleId)
                .Index(t => t.EncabezadoId);
            
            CreateTable(
                "dbo.BaseImponibles",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Nombre = c.String(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Encabezados",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Periodo = c.String(nullable: false),
                        Ruc = c.Long(nullable: false),
                        Razon_Social = c.String(nullable: false),
                        Estado = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Proveedores",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Tabla2Id = c.Int(nullable: false),
                        Numero = c.Long(nullable: false),
                        RazonSocial = c.String(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Tabla2s", t => t.Tabla2Id)
                .Index(t => t.Tabla2Id);
            
            CreateTable(
                "dbo.Tabla2s",
                c => new
                    {
                        Id = c.Int(nullable: false),
                        Descripcion = c.String(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.ReferenciaComprobantes",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Fecha = c.DateTime(nullable: false),
                        Tabla10Id = c.Int(nullable: false),
                        Serie = c.String(nullable: false),
                        N_Comprobante = c.Long(nullable: false),
                        Base1Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Base1s", t => t.Base1Id)
                .ForeignKey("dbo.Tabla10s", t => t.Tabla10Id)
                .Index(t => t.Tabla10Id)
                .Index(t => t.Base1Id);
            
            CreateTable(
                "dbo.Tabla10s",
                c => new
                    {
                        Id = c.Int(nullable: false),
                        Descripcion = c.String(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Elementos",
                c => new
                    {
                        Id = c.Int(nullable: false),
                        Descripcion = c.String(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Base1s", "Tabla10Id", "dbo.Tabla10s");
            DropForeignKey("dbo.ReferenciaComprobantes", "Tabla10Id", "dbo.Tabla10s");
            DropForeignKey("dbo.ReferenciaComprobantes", "Base1Id", "dbo.Base1s");
            DropForeignKey("dbo.Base1s", "ProveedorId", "dbo.Proveedores");
            DropForeignKey("dbo.Proveedores", "Tabla2Id", "dbo.Tabla2s");
            DropForeignKey("dbo.Base1s", "EncabezadoId", "dbo.Encabezados");
            DropForeignKey("dbo.Base1s", "BaseImponibleId", "dbo.BaseImponibles");
            DropIndex("dbo.ReferenciaComprobantes", new[] { "Base1Id" });
            DropIndex("dbo.ReferenciaComprobantes", new[] { "Tabla10Id" });
            DropIndex("dbo.Proveedores", new[] { "Tabla2Id" });
            DropIndex("dbo.Base1s", new[] { "EncabezadoId" });
            DropIndex("dbo.Base1s", new[] { "BaseImponibleId" });
            DropIndex("dbo.Base1s", new[] { "ProveedorId" });
            DropIndex("dbo.Base1s", new[] { "Tabla10Id" });
            DropTable("dbo.Elementos");
            DropTable("dbo.Tabla10s");
            DropTable("dbo.ReferenciaComprobantes");
            DropTable("dbo.Tabla2s");
            DropTable("dbo.Proveedores");
            DropTable("dbo.Encabezados");
            DropTable("dbo.BaseImponibles");
            DropTable("dbo.Base1s");
        }
    }
}
